package oss.aliyun.springai.tool;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;
import oss.aliyun.springai.entity.po.Course;
import oss.aliyun.springai.entity.coursequery;
import oss.aliyun.springai.service.ICourseService;

import java.util.List;
import java.util.Objects;

/**
 * @Author: 陈杰
 * @Date: 2025/6/2 14:18
 * @Description:
 * @PackageName: oss.aliyun.springai.tool
 * @Version: 1.0
 * @Since: 1.0
 */
 @Component
 @Slf4j
  @RequiredArgsConstructor
public class coursetool {
     private final ICourseService courseService;
     @Tool( description = "根据条件查询课程信息")
      public List<Course> conditionQuery(@ToolParam(description = "查询条件") coursequery query) {
          return courseService.lambdaQuery()
                  .eq(!Objects.equals(query.getDegree(), ""),Course::getDegree, query.getDegree())
                  .eq(!Objects.equals(query.getRegion(), ""),Course::getRegion, query.getRegion())
                  .like(!Objects.equals(query.getCourseName(), ""),Course::getCourseName, query.getCourseName())
                  .list();
     }
}
